package com.troyhigh.njrotc.admintrackerold;

import java.util.ArrayList;

public class RibbonData
{
    private int id = 0;
    private int[] data = new int[25];
    private ArrayList<String> quicklookup;
    
    public RibbonData(int d, int[] newData)
    {
        this();
        data = newData;
        id = d;
    }
    
    public RibbonData(int d)
    {
        this();
        id = d;
    }
    
    public RibbonData()
    {
        quicklookup = new ArrayList<String>();
        String[] arr = {"ma", "du", "dc", "hc", "ca", "ua", "ap", "n4", "n3",
                        "n2", "n1", "ec", "aa", "ep", "pf", "pa", "us", "cs",
                        "dt", "cg", "rt", "oi", "re", "bl", "sc"};
        for(String s : arr)
            quicklookup.add(s);
    }
    
    public boolean hasNoData()
    {
        for(int i : data)
        {
            if( i >= 1) return false;
        }
        return true;
    }
    
    public int getID()
    {
        return id;
    }
    
    public void setID(int d)
    {
        id = d;
    }
    
    public int get(int ind)
    {
        return data[ind];
    }
    
    public int get(String ind)
    {
        int idx = quicklookup.lastIndexOf(ind);
        if(idx == -1) return 0;
        return data[idx];
    }
    
    public int get(Category c)
    {
        if(c.toString().equals("DRILL"))
            return get("dt");
        else if(c.toString().equals("ACADEMICS"))
            return get("aa");
        else if(c.toString().equals("COLOR GUARD"))
            return get("cg");
        else if(c.toString().equals("PT"))
            return get("pt");
        else if(c.toString().equals("ORIENTEERING"))
            return get("oi");
        else if(c.toString().equals("MARKSMANSHIP"))
            return get("rt");
        else if(c.toString().equals("UNIT SERIVCE"))
            return get("us");
        else if(c.toString().equals("COMMUNITY SERVICE"))
            return get("cs");
        else if(c.toString().equals("PARTICIPATION"))
            return get("pa");
        else if(c.toString().equals("MINI BOOT CAMP"))
            return get("bl");
        else if(c.toString().equals("SEA CRUISE"))
            return get("sc");
        return 0;
    }
    
    public void set(int ind, int val)
    {
        data[ind] = val;
    }
    
    public void set(String ind, int val)
    {
        int idx = quicklookup.lastIndexOf(ind);
        if(idx == -1) return;
        data[idx] = val;
    }
    
    public void load(int[] arr)
    {
        if(arr.length != data.length) return;
        for(int idx = 0; idx < arr.length; idx++)
            data[idx] = arr[idx];
    }
    
    public String toString()
    {
        return "[RIBBON DATA FOR " + id + "]";
    }
    
    public static String formattedLabels()
    {
        String[] arr = {"ma", "du", "dc", "hc", "ca", "ua", "ap", "n4", "n3",
                        "n2", "n1", "ec", "aa", "ep", "pf", "pa", "us", "cs",
                        "dt", "cg", "rt", "oi", "re", "bl", "sc"};
        String result = "(id, ";
        for(String s : arr)
        {
            result += s + ", ";
        }
        result = result.substring(0, result.length() - 2);
        result += ")";
        return result;
    }
    
    public String stringValues()
    {
        String[] arr = {"ma", "du", "dc", "hc", "ca", "ua", "ap", "n4", "n3",
                        "n2", "n1", "ec", "aa", "ep", "pf", "pa", "us", "cs",
                        "dt", "cg", "rt", "oi", "re", "bl", "sc"};
        String result = "id=" + id + ", ";
        for(int i = 0; i < data.length; i++)
            result += arr[i] + "=" + data[i]+ ", ";
        result = result.substring(0, result.length() - 2);
        return result;
    }
    
    public String valuesOnly()
    {
        String result = "";
        for(int i = 0; i < data.length; i++)
        {
            result += data[i] + ", ";
        }
        return result.substring(0, result.length() -2);
    }
}